//
//  BankCardsViewController.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/5.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "BankCardsViewController.h"
#import "BankCardsViewModel.h"
#import "BankCardListViewController.h"
#import "WithDrawalDoneViewController.h"

@interface BankCardsViewController ()

@property (nonatomic, strong) BankCardsViewModel *viewModel;
@end

@implementation BankCardsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"选择银行卡";
    self.viewModel = [[BankCardsViewModel alloc] initWithViewToViewModel:self.groupedTableView theSuperView:self.view];
    kWeakSelf(self);
    self.viewModel.BlockChooseBank = ^{
        [weakself chooseBank];
    };
    self.viewModel.BlockApplyWithDraw = ^(GLGWButton * _Nullable applyWithDraw) {
        [weakself applyWithDraw:applyWithDraw];
    };
}

- (void)chooseBank
{
    BankCardListViewController *vc = [[BankCardListViewController alloc] init];
    vc.type = ChooseCardType_Return;
    kWeakSelf(self);
    vc.BlockChooseBank = ^(NSDictionary * _Nullable dic) {
        [weakself choosedBank:dic];
    };
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)choosedBank:(NSDictionary *)dic
{
    DLog(@"选择回来了");
    self.viewModel.bankCardType = BankCardsType_Cars;
    [self.viewModel reloadUI];
}

- (void)applyWithDraw:(GLGWButton *)sender
{
    WithDrawalDoneViewController *vc = [[WithDrawalDoneViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
